package com.jluzh.low_level.com.jluzh.controller;

import com.jluzh.low_level.com.jluzh.model.Book;
import com.jluzh.low_level.com.jluzh.model.BookView;
import com.jluzh.low_level.com.jluzh.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author EvanHuang
 * @date 1/23/2019 11:14 AM
 * @since
 */

@RestController
@RequestMapping(value = "/book")
public class BookController {
    @Autowired
    private BookService bookService;

    @GetMapping("/{id}")
    public BookView findBook(@PathVariable("id") Long id) {
        BookView book = bookService.findBook(id);
        return book;
    }

    @PostMapping("/new")
    public String createBook() {
        bookService.createBook();
        return "success";
    }
}
